package com.cstz.ydshop.common.utils;

import java.util.Map;

/**
 * @author ccs.nzzhpt
 */
public class StringUtils extends org.apache.commons.lang3.StringUtils{
	public static String getMapStr(Map<String, Object> dataMap,String key){
		Object o = dataMap.get(key);
		if(o==null){
			return null;
		}
		
		return o.toString();
	}
	
	public static Integer getMapInt(Map dataMap,String key){
		Object o = dataMap.get(key);
		if(o==null){
			return null;
		}
		
		return Integer.parseInt(o.toString());
	}
	
	public static String fmtPx(String content){
		
		if(StringUtils.isNotBlank(content)){
			String s = "";
			s = s+"<!DOCTYPE html>";
			s = s+"<html lang=\"en\">";
			s = s+"<head>";
			s = s+"    <meta charset=\"utf-8\">";
			s = s+"    <meta http-equiv=\"X-UA-Compatible\" content=\"IE=edge\">";
			s = s+"    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0\"/>";
			s = s+"</head>";
			s = s+"<body>";
			
			for(int i=10;i<=30;i++){
				content = StringUtils.replaceAll(content, i+"px", (i*0.0625)+"em");
			}
			
			s = s + content;
			s = s+"</body>";
			s = s+"</html>";
			
			return s;
			/*
			content = StringUtils.replaceAll(content, "12px", "0.75em");
			content = StringUtils.replaceAll(content, "14px", "0.875em");
			content = StringUtils.replaceAll(content, "16px", "1em");
			content = StringUtils.replaceAll(content, "18px", "1.125em");
			content = StringUtils.replaceAll(content, "20px", "1.25em");
			content = StringUtils.replaceAll(content, "24px", "1.5em");*/
		}
		
		return content;
	}
	
	public static void main(String[] args) {
		for(int i=10;i<=30;i++){
			System.out.println(i+"px   :    "+(i*0.0625)+"em");
		}
	}
}
